$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_zjjh_m")
    const dgrid1 = $NG.getCmpApi("")
    const getHeadValue = (str) => mstform.getItem(str).getValue()

    useValuesChange(() => {
        getXmkInfoByPhid()
    }, "p_form_zjjh_m.u_xmmc")

    useValuesChange(() => {
        // 定义一个变量存储持股比例
        const sharePercentage = ((Number(mstform.getItem("u_cgbl").getValue()) || 0))

        // 定义一个变量用于存储最终的持股形式
        let holdingType;

        // 根据持股比例的值，为holdingType变量赋予相应的描述
        if (sharePercentage < 15) {
            holdingType = '01';
        } else if (sharePercentage < 50) {
            holdingType = '02';
        } else if (sharePercentage < 100) {
            holdingType = '03';
        } else if (sharePercentage === 100) {
            holdingType = '04';
        }
        mstform.getItem("u_cgxs").setValue(holdingType)
    }, "p_form_zjjh_m.u_cgbl")

    // 获取项目库信息
    function getXmkInfoByPhid() {
        const phid = getHeadValue("u_xmmc")
        if (!phid) return
        $NG.execServer("getXmkInfoByPhid", { phid }, (res) => {
            if (res.count == 0) return
            const datas = JSON.parse(res.data)[0].extendObjects
            $NG.updateState((updater) => {
                updater.data.p_form_zjjh_m.setProps({
                    bill_no: datas.u_xmbh,
                    u_gctze: datas.u_ztzje,
                })
            })
        })
    }
})
